using IrisGenerator.Common.Core;
using IrisGenerator.Common.Tools;
namespace IrisGenerator.Common.Modules
{


    public partial class FormaterConfiguration
    {

        private string _forConConfigKey;

        private System.Nullable<System.Guid> _casId;

        private System.Nullable<System.Guid> _forId;

        private string _forConPrefix;

        private string _forConSuffix;

        private Casing _casing;

        private Formater _formater;

        private FormaterReplacementCharsCollection _formaterReplacementCharsCollection;

        public virtual string ForConConfigKey
        {
            get
            {
                return _forConConfigKey;
            }
            set
            {
                _forConConfigKey = value;
            }
        }

        public virtual string ForConPrefix
        {
            get
            {
                return _forConPrefix;
            }
            set
            {
                _forConPrefix = value;
            }
        }

        public virtual string ForConSuffix
        {
            get
            {
                return _forConSuffix;
            }
            set
            {
                _forConSuffix = value;
            }
        }

        public virtual Casing Casing
        {
            get
            {
                if ((this._casing == null))
                {
                    this._casing = Casing.Load(this._casId);
                }
                return this._casing;
            }
            set
            {
                _casing = value;
            }
        }

        public virtual Formater Formater
        {
            get
            {
                if ((this._formater == null))
                {
                    this._formater = Formater.Load(this._forId);
                }
                return this._formater;
            }
            set
            {
                _formater = value;
            }
        }

        public virtual FormaterReplacementCharsCollection FormaterReplacementCharsCollection
        {
            get
            {
                if ((this._formaterReplacementCharsCollection == null))
                {
                    _formaterReplacementCharsCollection = FormaterReplacementChars.Select_FORMATER_REPLACEMENT_CHARS_By_FOR_CON_CONFIG_KEY(this.ForConConfigKey);
                }
                return this._formaterReplacementCharsCollection;
            }
        }

        private void Clean()
        {
            this.ForConConfigKey = string.Empty;
            this._casId = null;
            this._forId = null;
            this.ForConPrefix = string.Empty;
            this.ForConSuffix = string.Empty;
            this.Casing = null;
            this.Formater = null;
            this._formaterReplacementCharsCollection = null;
        }

        private void Fill(System.Data.DataRow dr)
        {
            this.Clean();
            if ((dr["FOR_CON_CONFIG_KEY"] != System.DBNull.Value))
            {
                this.ForConConfigKey = ((string)(dr["FOR_CON_CONFIG_KEY"]));
            }
            if ((dr["CAS_ID"] != System.DBNull.Value))
            {
                this._casId = ((System.Nullable<System.Guid>)(dr["CAS_ID"]));
            }
            if ((dr["FOR_ID"] != System.DBNull.Value))
            {
                this._forId = ((System.Nullable<System.Guid>)(dr["FOR_ID"]));
            }
            if ((dr["FOR_CON_PREFIX"] != System.DBNull.Value))
            {
                this.ForConPrefix = ((string)(dr["FOR_CON_PREFIX"]));
            }
            if ((dr["FOR_CON_SUFFIX"] != System.DBNull.Value))
            {
                this.ForConSuffix = ((string)(dr["FOR_CON_SUFFIX"]));
            }
        }

        public static FormaterConfigurationCollection Select_FORMATER_CONFIGURATION_By_CAS_ID(System.Nullable<System.Guid> CAS_ID)
        {
            IrisGenerator.Dal.FormaterConfiguration dbo = null;
            try
            {
                dbo = new IrisGenerator.Dal.FormaterConfiguration();
                System.Data.DataSet ds = dbo.Select_FORMATER_CONFIGURATION_By_CAS_ID(CAS_ID);
                FormaterConfigurationCollection collection = new FormaterConfigurationCollection();
                if (GlobalTools.IsSafeDataSet(ds))
                {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1))
                    {
                        FormaterConfiguration obj = new FormaterConfiguration();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null))
                        {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }

        public static FormaterConfigurationCollection Select_FORMATER_CONFIGURATION_By_FOR_ID(System.Nullable<System.Guid> FOR_ID)
        {
            IrisGenerator.Dal.FormaterConfiguration dbo = null;
            try
            {
                dbo = new IrisGenerator.Dal.FormaterConfiguration();
                System.Data.DataSet ds = dbo.Select_FORMATER_CONFIGURATION_By_FOR_ID(FOR_ID);
                FormaterConfigurationCollection collection = new FormaterConfigurationCollection();
                if (GlobalTools.IsSafeDataSet(ds))
                {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1))
                    {
                        FormaterConfiguration obj = new FormaterConfiguration();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null))
                        {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }

        public static FormaterConfigurationCollection GetAll()
        {
            IrisGenerator.Dal.FormaterConfiguration dbo = null;
            try
            {
                dbo = new IrisGenerator.Dal.FormaterConfiguration();
                System.Data.DataSet ds = dbo.FORMATER_CONFIGURATION_Select_All();
                FormaterConfigurationCollection collection = new FormaterConfigurationCollection();
                if (GlobalTools.IsSafeDataSet(ds))
                {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1))
                    {
                        FormaterConfiguration obj = new FormaterConfiguration();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null))
                        {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }

        public static FormaterConfiguration Load(string FOR_CON_CONFIG_KEY)
        {
            IrisGenerator.Dal.FormaterConfiguration dbo = null;
            try
            {
                dbo = new IrisGenerator.Dal.FormaterConfiguration();
                System.Data.DataSet ds = dbo.FORMATER_CONFIGURATION_Select_One(FOR_CON_CONFIG_KEY);
                FormaterConfiguration obj = null;
                if (GlobalTools.IsSafeDataSet(ds))
                {
                    if ((ds.Tables[0].Rows.Count > 0))
                    {
                        obj = new FormaterConfiguration();
                        obj.Fill(ds.Tables[0].Rows[0]);
                    }
                }
                return obj;
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }

        public virtual void Load()
        {
            IrisGenerator.Dal.FormaterConfiguration dbo = null;
            try
            {
                dbo = new IrisGenerator.Dal.FormaterConfiguration();
                System.Data.DataSet ds = dbo.FORMATER_CONFIGURATION_Select_One(this.ForConConfigKey);
                if (GlobalTools.IsSafeDataSet(ds))
                {
                    if ((ds.Tables[0].Rows.Count > 0))
                    {
                        this.Fill(ds.Tables[0].Rows[0]);
                    }
                }
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }

        public virtual void Insert()
        {
            IrisGenerator.Dal.FormaterConfiguration dbo = null;
            try
            {
                dbo = new IrisGenerator.Dal.FormaterConfiguration();
                dbo.FORMATER_CONFIGURATION_Insert(this.ForConConfigKey, this._casId, this._forId, this.ForConPrefix, this.ForConSuffix);
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }

        public virtual void Delete()
        {
            IrisGenerator.Dal.FormaterConfiguration dbo = null;
            try
            {
                dbo = new IrisGenerator.Dal.FormaterConfiguration();
                dbo.FORMATER_CONFIGURATION_Delete(this.ForConConfigKey);
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }

        public virtual void Update()
        {
            IrisGenerator.Dal.FormaterConfiguration dbo = null;
            try
            {
                dbo = new IrisGenerator.Dal.FormaterConfiguration();
                dbo.FORMATER_CONFIGURATION_Update(this.ForConConfigKey, this._casId, this._forId, this.ForConPrefix, this.ForConSuffix);
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }
    }
}
